﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Yottamud_2013_v3_Main
{
    /// <summary>
    /// Interaction logic for PlayerSettings.xaml
    /// </summary>
    public partial class PlayerSettings : Window
    {
        public struct PlayerSetting
        {
            public string LabelName;
            public int SettingValue;
        }

        public List<PlayerSetting> Settings = new List<PlayerSetting>();

        public PlayerSettings(bool isSet)
        {
            InitializeComponent();

            if (!isSet)
            {
                CreateSettings();
            }
            else
            {
                LoadSettings();
            }

            DisplaySettings();
        }

        private void SaveSettings()
        {
            // Save xml file settings
        }

        private void LoadSettings()
        {
            // Load xml file settings
        }

        private void CreateSettings()
        {

            Settings.Add(new PlayerSetting { LabelName = "Rest Until", SettingValue = 0 });
            Settings.Add(new PlayerSetting { LabelName = "Rest When Below", SettingValue = 0 });






        }

        private void DisplaySettings()
        {
            this.healthSettingLayout.ColumnDefinitions.Clear();
            this.healthSettingLayout.RowDefinitions.Clear();

            this.healthSettingLayout.ColumnDefinitions.Add(new ColumnDefinition());
            this.healthSettingLayout.ColumnDefinitions.Add(new ColumnDefinition());

            for (int i = 0; i < Settings.Count; i++)
            {
                this.healthSettingLayout.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

                Label nameLabel = new Label(); nameLabel.Content = Settings[i].LabelName;

                NumericBox.NumericBox dataLabel = new NumericBox.NumericBox();

                dataLabel.Maximum = 100;
                dataLabel.Minimum = 0;
                dataLabel.ValueFormat = "0";

                dataLabel.Value = Settings[i].SettingValue;

                Grid.SetRow(nameLabel, i);
                Grid.SetRow(dataLabel, i);

                Grid.SetColumn(nameLabel, 0);
                Grid.SetColumn(dataLabel, 1);


                this.healthSettingLayout.Children.Add(nameLabel);
                this.healthSettingLayout.Children.Add(dataLabel);
              
            }
        }
    }
}
